package Server;

import java.io.BufferedReader;
import java.io.FileReader;
import java.net.ServerSocket;
import java.util.ArrayList;

public class serverModel {

	protected serverView view;
	private int port = 50001;
	private ServerSocket SRVSOCK;
	private ArrayList clientConnections = new ArrayList();

	public serverModel(serverView view) {
		this.view = view;
	}

	public void startServer() {
		view.txtA_message.append("Server started. Port: "+port);
		view.cPanel.btn_start_Server.setEnabled(false);
		view.cPanel.btn_stop_Server.setEnabled(true);
		// BufferedReader file = new BufferedReader(new
		// FileReader("userinfo.txt"));

		// SRVSOCK = new ServerSocket(port);
		// while (true) {
		// Socket client = SRVSOCK.accept();
		// }
	}

	public void stopServer() {
		view.txtA_message.append("Server stopped\n");
		view.txtA_message.append("Disconnecting all users..\n");
		view.cPanel.btn_stop_Server.setEnabled(false);
		view.cPanel.btn_start_Server.setEnabled(true);
		// SRVSOCK.close(); //Forbid to connect
		//
		// for(ClientThread a; clientConnections){ //disconnect all users
		// a.close
		// }

		// view.cPanel.txtA_message.setText("test\n");
	}

	public void broadcast() {

	}
}
